﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Biblioteca.Utils;
using Biblioteca.Objetos;
using Pms.Utils;

namespace SERIX
{
    public partial class FiltroQuestBenef : System.Web.UI.Page
    {
        Usuario usuAut;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session.Count == 0)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                usuAut = (Usuario)Session["usuario"];
                if (!Page.IsPostBack)
                {

                    char perm = BiblioPMS.VerifiquePermissao("FILTROQUESTBENEF.ASPX", BiblioPMS.aplicacaoSGA, usuAut.Login);
                    if (perm.Equals(Constantes.PERM_NEGADA))
                    {
                        Response.Redirect("Logged.aspx");
                    }
                }
            }
        }

        protected void btnOk_Click(object sender, EventArgs e)
        {
            string tpofile = ".pdf";
            //Verifica a extensao para a qual o arquivo será exportado
            if (ddlTipoArquivo.SelectedValue == ".pdf")
                tpofile = Server.UrlEncode(Criptografia.Criptografar(".pdf"));
            else if (ddlTipoArquivo.SelectedValue == ".xls")
                tpofile = Server.UrlEncode(Criptografia.Criptografar(".xls"));
            else
                tpofile = Server.UrlEncode(Criptografia.Criptografar(".doc"));

            Response.Redirect("Relatorios/ViewRelatorios.aspx?relat=" + Server.UrlEncode(Criptografia.Criptografar("2")) +
                              "&datIni=" + Server.UrlEncode(Criptografia.Criptografar(txtDataIniQuest.Text)) + "&datFim=" + Server.UrlEncode(Criptografia.Criptografar(txtDataFimQuest.Text)) + "&tpofile=" + tpofile);

        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("logged.aspx");
        }
    }
}
